<?php
require('upyun.class.php');

$upyun = new UpYun('studying', 'dada', 'qawsed1234');

try {
    echo "=========获取目录文件列表\r\n";
    $list = $upyun->getList('/');
    echo "=========DONE\r\n\r\n";
?>
    <table>
    <tr>
        <th>文件名</th>
        <th>文件大小</th>
        <th>创建时间</th>
        <th>略缩图</th>
    </tr>

<?php
    foreach ($list as $i => $folder) {
        $cur_folder = $folder['name'];
        echo('<br/>'.$cur_folder.'<br/>');
        $files_list = $upyun->getList('/'.$cur_folder.'/');
        foreach ($files_list as $j => $files) {
?>
            <tr>
            <td><?php echo($files['name']); ?></td>
            <td><?php echo($files['size']/1000 . 'Kb'); ?></td>
            <td><?php echo(date(("F j, Y, g:i a"),$files['time']));?></td>
<!--            <td>--><?php // $data = $upyun->readFile('/'.$cur_folder.'/'.$files['name']);
//                $base64 = chunk_split(base64_encode($data));
//                $tag = '<img ' . "n" .
//                    'src="data:image/gif;base64,' . $base64 .
//                    '" alt="British Blog Directory" width="80" height="15" />';
//                echo $tag;?><!--" />-->
<!--            </td>-->
            </tr>
<?php
        }

    }
    echo('</table>');
}
catch(Exception $e) {
    echo $e->getCode();
    echo $e->getMessage();
}
